package com.iot.inter.utils;

import com.alibaba.fastjson.JSON;
import com.iot.inter.entity.newrequest.order.purchaseplan.response.PurchasePlanResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

@Component
public class ResponseUtil {

    private static Logger logger = Logger.getLogger(ResponseUtil.class);

    /***
     * 规范返回
     * @param retCode
     * @param resultInfo
     * @return
     */
    public static String responseStr(String retCode, String resultInfo, String orderId, String startDate, String expireDate) {

        PurchasePlanResponse response = new PurchasePlanResponse();
        response.setRetCode(retCode);
        response.setResultInfo(resultInfo);
        response.setOrderId(orderId);
        response.setOrderStartDate(startDate);
        response.setOrderExpireDate(expireDate);
        // 返回给调用者的报文
        String jsonString = JSON.toJSONString(response);
        logger.info("【真正订购套餐】：" + resultInfo + "响应：" + jsonString);
        return jsonString;

    }
}
